// 大厅UI预制体管理

let uiCreatorHome = function() {
    let that = {};

    that.addPrefab = (prefab)=>{
        var node = cc.instantiate(prefab);
        cc.director.getScene().getChildByName('Canvas').addChild(node);
        node.setPosition(cc.p(0, 0));
    };

    // 创建房间界面
    that.createRoom = function () {
        cc.loader.loadRes("Prefabs/HomeRoom/CreateRoom", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 进入房间界面
    that.createJoinRoom = function () {
        cc.loader.loadRes("Prefabs/HomeRoom/JoinRoom", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 头像界面
    that.createIcon = function (data) {
        cc.loader.loadRes("Prefabs/HomeRoom/IconBox", (err, prefab)=>{
            if (!err) {
                var node = cc.instantiate(prefab);
                cc.director.getScene().getChildByName('Canvas').addChild(node);
                node.getComponent("IconBox").SetIconInfo(data);
                node.setPosition(cc.p(0, 0));
            }
        });
    };

    // 福利界面
    that.createWelfare = function () {
        cc.loader.loadRes("Prefabs/HomeRoom/WelfareInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 战绩界面
    that.createRecord = function() {
        cc.loader.loadRes("Prefabs/HomeRoom/RecordInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 帮助界面
    that.createHelp = function () {
        cc.loader.loadRes("Prefabs/HomeRoom/HelpInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 活动界面
    that.createActivity = function() {
        cc.loader.loadRes("Prefabs/HomeRoom/ActivityInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 分享界面
    that.createShare = function() {
        cc.loader.loadRes("Prefabs/HomeRoom/ShareInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 设置界面
    that.createSetUp = function() {
        cc.loader.loadRes("Prefabs/HomeRoom/SetUpInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };

    // 设置界面
    that.createScore = function() {
        cc.loader.loadRes("Prefabs/HomeRoom/ScoreInterface", (err, prefab)=>{
            if (!err) {
                this.addPrefab(prefab);
            }
        });
    };




    return that;
};
export default uiCreatorHome;